//
//  BBTimePicker.m
//  BearSiX
//
//  Created by BearBaby on 16/3/26.
//  Copyright © 2016年 Tom. All rights reserved.
//

#import "BBTimePicker.h"
#import "BBSixHeader.h"
@implementation BBTimePicker

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self onCreate];
    }
    return self;
}
- (NSString*)formatDate:(NSDate *)date
{
    // A convenience method that formats the date in Month-Year format
    
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"MMMM-yy-dd HH:mm";
    return [formatter stringFromDate:date];
}
-(void)onCreate
{
    //取消按钮
    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setBackgroundColor:[UIColor colorWithHexString:@"61636e"]];
    cancelBtn.layer.cornerRadius = 5;
    cancelBtn.layer.masksToBounds = YES;
    [cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    cancelBtn.titleLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/25];
    cancelBtn.frame = CGRectMake(WINSIZEWIDTH/7, 10, WINSIZEWIDTH/7*2, 40);
    cancelBtn.tag = 6004;
    [self addSubview:cancelBtn];
    //确定按钮
    UIButton *ensureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [ensureBtn setTitle:@"确定" forState:UIControlStateNormal];
    [ensureBtn setBackgroundColor:[UIColor colorWithHexString:@"e6742e"]];
    ensureBtn.layer.cornerRadius = 5;
    ensureBtn.layer.masksToBounds = YES;
    [ensureBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    ensureBtn.titleLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/25];

    ensureBtn.frame = CGRectMake(WINSIZEWIDTH/7*4, 10, WINSIZEWIDTH/7*2, 40);
    ensureBtn.tag = 6005;
    [self addSubview:ensureBtn];
    UIDatePicker* datePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(ensureBtn.frame)+10, self.frame.size.width, 216)];
    NSLocale* locale = [[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"];
    datePicker.locale = locale;
    datePicker.tag = 6003;
    datePicker.datePickerMode = UIDatePickerModeDateAndTime;
    [self addSubview:datePicker];
}
@end
